package top.zhangjianyong.tools.utils;

import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * @author ： zhangjianyong
 * @date ： 2022/4/30 9:05 AM
 */
public class ExceptionUtil {

    /**
     * 将 Exception 转化为 String
     */
    public static String getExceptionToString(Exception e) {
        if (e == null) {
            return "";
        }
        StringWriter stringWriter = new StringWriter();
        e.printStackTrace(new PrintWriter(stringWriter));
        stringWriter.append("\n");
        return stringWriter.toString();
    }

}
